import {request} from '../request';

/**
 * 登录请求
 *
 * @param username 用户名
 * @param password 密码
 * @param rememberMe 记住我
 */
export function fetchLogin(username: string, password: string, rememberMe: boolean) {
  return request<Api.Auth.LoginToken>({
    url: '/auth/login',
    method: 'post',
    data: {
      username,
      password,
      rememberMe
    }
  });
}

//获取用户信息
export function fetchGetUserInfo() {
  return request<Api.Entity.User>({
    url: '/auth/getUserInfo',
    method: 'post',
    data: {}
  });
}

/**
 * 刷新token
 *
 * @param refreshToken 刷新token
 */
export function fetchRefreshToken(refreshToken: string) {
  return request<Api.Auth.LoginToken>({
    url: '/auth/refreshToken',
    method: 'post',
    data: {
      refreshToken
    }
  });
}

export function fetchDebug() {
  return request<string>({
    url: '/debug-post',
    method: 'post',
    headers: {'content-type': 'application/x-www-form-urlencoded'},
    data: {
      a: '1'
    }
  });
}
